<cfsetting enablecfoutputonly="true">

<cfset Request.PageTitle="NaNoWriMo Progress Graph Wizard">
<cfset Args=StructNew()>
<cfset EvenOdd=ListToArray("odd,even")>
<cfset StructAppend(Args,Form,false)>
<cfset StructAppend(Args,URL,false)>
<cfset ParamNames="Terms,Username,UID,Format,Tweaked">
<cfloop list="#ParamNames#" index="ParamName">
	<cfparam name="Args.#ParamName#" default="">
	<cfset Args[ParamName]=Trim(Args[ParamName])>
</cfloop>
<cfset Hidden=ArrayNew(1)>
<cfset Renderer="n7.cfm">
<cfset Request.UrchinPage="">

<cfinclude template="_header.cfm">

<cfoutput>
<!-- #CGI.REMOTE_ADDR# -->
<form name="nanowizard" id="nanowizard" method="get" action="#CGI.SCRIPT_NAME#" class="wizard">
<h1>#Request.PageTitle#</h1>
</cfoutput>

<cfif Args.Terms EQ "I promise to play nice.">
	<cfset ArrayAppend(Hidden,"Terms")>
	<cfset NG=CreateObject("component","com.nowrists.NaNoWriMoGateway2007")>
	<cfif IsNumeric(Args.UID)>
		<cfset Users=NG.UserInfo(Args.UID)>
		<cfif Users.RecordCount EQ 1>
			<cfset Args.Username=Users.Username>
		</cfif>
	</cfif>
	<cfset Users=NG.FindUserAsQuery(Args.UID)>
	<cfif Users.RecordCount EQ 1>
		<cfset ArrayAppend(Hidden,"Username")>
		<cfset ArrayAppend(Hidden,"UID")>
		<cfif (ListFindNoCase("Grey,Blue,Dash,Palm,Stereo",Args.Format) GT 0)>
			<cfset ArrayAppend(Hidden,"Format")>
			<cfset ImgWidth=400>
			<cfset ImgHeight=100>
			<cfif Args.Format EQ "Dash">
				<cfset ImgWidth=300>
			<cfelseif Args.Format EQ "Stereo">
				<cfset ImgWidth=320>
				<cfset ImgHeight=96>
			</cfif>
			<cfif Args.Tweaked EQ "yep">
				<cfset ImageLink="http://#CGI.SERVER_NAME#/#Renderer#/#Users.UID#/#HTMLEditFormat(Format)#">
				<cfloop list="NoPace,NoNovelTitle,NoWordCount,AddEta" index="NoName">
					<cfif StructKeyExists(Args,NoName)>
						<cfset ImageLink=ImageLink & "/" & NoName>
					</cfif>
				</cfloop>
				<cfif StructKeyExists(Args,"Goal") AND StructKeyExists(Args,"GoalCount") AND IsNumeric(Args.GoalCount)>
					<cfset ImageLink=ImageLink & "/Goal" & ReReplace(Args.GoalCount,"[^0-9]+","","ALL")>
				</cfif>
				<cfset ImageLink=ImageLink & "/n.png">
				<cfset Request.UrchinPage=Request.Path & "/link">
				<cfoutput>
<h2>Step 4: omg ponies!</h2>
<p align="center"><img src="#ImageLink#" width="#ImgWidth#" height="100" alt="Your NaNoGraph" border="0" id="example" />
<p>You are done!  You can now copy the following code segments to use your image on your blog, forums, or whatever.</p>
<dl>
	<dt>Image Link</dt>
	<dd><a href="#ImageLink#">#ImageLink#</a></dd>
	<dt>HTML</dt>
	<dd>(for LiveJournal, most blogs, and the NaNoWriMo forums)
		<code>&lt;img src="#ImageLink#" width="#ImgWidth#" height="#ImgHeight#" border="0" alt="My NaNoWriMo Progress" /&gt;</code>
	</dd>
	<dt>BBCode</dt>
	<dd>(for some message boards)
		<code>[img]#ImageLink#[/img]</code>
	</dd>
</dl>
				</cfoutput>
			<cfelse>
				<cfset Request.UrchinPage=Request.Path & "/options">
				<cfoutput>
<h2>Step 3: Tweak it</h2>
<p>There are also a few options you can tweak:</p>
<script language="javascript" type="text/javascript">
<!--
function updateExample() {
	var np = document.getElementById('NoPace');
	var nt = document.getElementById('NoNovelTitle');
	var nwc = document.getElementById('NoWordCount');
	var eta = document.getElementById('AddEta');
	var g = document.getElementById('Goal');
	var gc = document.getElementById('GoalCount');
	var ex = document.getElementById('example');
	ex.src = '#Renderer#/#Users.UID#/#HTMLEditFormat(Format)#' + (np.checked ? '/NoPace' : '') + (nt.checked ? '/NoNovelTitle' : '') + (nwc.checked ? '/NoWordCount' : '') + (eta.checked ? '/AddEta' : '') + (g.checked ? '/Goal' + gc.value.replace(/[^0-9]+/i,'') : '');
}
// -->
</script>
<table>
	<cfif (Args.Format EQ "Dash") OR (Args.Format EQ "Palm") OR (Args.Format EQ "Stereo")>
	<input type="hidden" id="NoPace" name="NoPaceDummy" value="" />
	<cfelse>
	<tr>
		<td><input type="checkbox" name="NoPace" id="NoPace" class="tweak" value="NoPace" onchange="updateExample()" onclick="updateExample()" /></td>
		<td><label for="NoPace">Hide the Pace line</label></td>
	</tr>
	</cfif>
	<tr>
		<td><input type="checkbox" name="NoNovelTitle" id="NoNovelTitle" class="tweak" value="NoNovelTitle" onchange="updateExample()" onclick="updateExample()" /></td>
		<td><label for="NoNovelTitle">Hide my Novel Title</label></td>
	</tr>
	<cfif Args.Format EQ "Dash">
	<input type="hidden" id="NoWordCount" name="NoWordCountDummy" value="" />
	<cfelse>
	<tr>
		<td><input type="checkbox" name="NoWordCount" id="NoWordCount" class="tweak" value="NoWordCount" onchange="updateExample()" onclick="updateExample()" /></td>
		<td><label for="NoWordCount">Hide my Word Count</label></td>
	</tr>
	</cfif>
	<cfif (Args.Format eq "Stereo")>
	<input type="hidden" id="AddEta" name="AddEtaDummy" value="" />
	<cfelse>
	<tr>
		<td><input type="checkbox" name="AddEta" id="AddEta" class="tweak" value="AddEta" onchange="updateExample()" onclick="updateExample()" /></td>
		<td><label for="AddEta">Add an estimated completion date</label></td>
	</tr>
	</cfif>
	<tr>
		<td><input type="checkbox" name="Goal" id="Goal" class="tweak" value="Goal" onchange="updateExample()" onclick="updateExample()" /></td>
		<td><label for="Goal">Change your goal wordcount:</label> <input type="text" value="50000" name="GoalCount" id="GoalCount" size="6" maxlength="6" onchange="updateExample()" /></td>
	</tr>
</table>
<p align="center"><img src="#Renderer#/#Users.UID#/#HTMLEditFormat(Format)#" width="#ImgWidth#" height="#ImgHeight#" alt="Your NaNoGraph" border="0" id="example" /></p>
<input type="hidden" name="Tweaked" value="yep" />
<input type="submit" value="Continue &gt;&gt;" />
				</cfoutput>
			</cfif>
		<cfelse>
			<cfset Request.UrchinPage=Request.Path & "/format">
			<cfoutput>
<h2>Step 2: Pick Your Poison</h2>
<p>Which type of graph would you like?</p>
<table border="0" style="border:0;">
	<tr>
		<td><input type="radio" name="Format" value="Grey" id="FormatGrey" /></td>
		<td style="padding-bottom:2em;">The blue line is your wordcount, while the grey line is your &ldquo;pace line&rdquo;.<br/><label for="FormatGrey"><img src="#Renderer#/#Users.UID#/Grey/n.png" width="400" height="100" alt="NaNoGraph Grey" border="0" /></label></td>
	</tr>
	<tr>
		<td><input type="radio" name="Format" value="Blue" id="FormatBlue" /></td>
		<td style="padding-bottom:2em;">Same as the last one, but transparent and rounder.<br/><label for="FormatBlue"><img src="#Renderer#/#Users.UID#/Blue/n.png" width="400" height="100" alt="NaNoGraph Blue" border="0" /></label></td>
	</tr>
	<tr>
		<td><input type="radio" name="Format" value="Dash" id="FormatDash" /></td>
		<td style="padding-bottom:2em;">The speedometer shows how you are doing compared to your pace &mdash; vertical is on pace, while drifting to the left is going too slow and to the right is ahead of pace.<br/><label for="FormatDash"><img src="#Renderer#/#Users.UID#/Dash/n.png" width="300" height="100" alt="NaNoGraph Dash" border="0" /></label></td>
	</tr>
<!--- 	<tr>
		<td><input type="radio" name="Format" value="Palm" id="FormatPalm" /></td>
		<td style="padding-top:2em;"><label for="FormatPalm"><img src="#Renderer#/#Users.UID#/Palm/n.png" width="400" height="100" alt="NaNoGraph Palm" border="0" /></label></td>
	</tr> --->
	<tr>
		<td><input type="radio" name="Format" value="Stereo" id="FormatStereo" /></td>
		<td style="padding-bottom:2em;">This one is a SparkLine &mdash; the equalizer at the bottom shows a level per day, where red and yellow are ahead of pace and a full green bar is right on pace.  The volume knob turns as your novel completes.<label for="FormatStereo"><img src="#Renderer#/#Users.UID#/Stereo/n.png" width="320" height="96" alt="NaNoGraph Stereo" border="0" /></label></td>
	</tr>
</table>
<input type="submit" value="Continue &gt;&gt;" />
			</cfoutput>
		</cfif>
	<cfelse>
		<cfset Request.UrchinPage=Request.Path & "/find">
		<cfoutput>
<h2>Step 1: Find your UID</h2>
<!--- <p>The first thing we need to do is get the unique login that identifies you on the NaNoWriMo web site.  I can find it for you if you give me your NaNoWriMo username or email address:</p> --->
<p>The first thing we need to do is get the unique number that identifies you on the NaNoWriMo web site.  Login to nano, then go to your <em>&ldquo;View Profile&rdquo;</em> page.  The web address for the page should have that number at the end:</p>
<p align="center"><img src="images/nano-uid.png" width="238" height="39" border="0"/></p>
<p>What's your UID number?</p>
<input type="text" name="UID" id="UID" size="32" />
<p>No, I'm not going to spam you.  And no, I will definitely not be asking you for your password.</p>
<input type="submit" value="Continue &gt;&gt;" />
		</cfoutput>
	</cfif>
<cfelse>
	<cfset Request.UrchinPage=Request.Path & "/terms">
	<cfoutput>
<h2>Step 0: Terms and Conditions</h2>
<p>This is really simple: <strong>don't be a jerk</strong>.  This service is provided at no charge to you, so play nice.</p>
<input type="button" value="I am a jerk!" onclick="location.href='http://www.disney.com/'" /> <input type="submit" value="I promise to play nice." id="Terms" name="Terms" />
	</cfoutput>
</cfif>

<cfloop from="1" to="#ArrayLen(Hidden)#" index="i">
	<cfoutput>
<input type="hidden" name="#Hidden[i]#" value="#HTMLEditFormat(Args[Hidden[i]])#" />
	</cfoutput>
</cfloop>

<cfoutput>
</form>
</cfoutput>

<cfinclude template="_footer.cfm">

<cfsetting enablecfoutputonly="false">